package demoMod.invincibleOne.powers;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.StrengthPower;
import demoMod.invincibleOne.InvincibleOneMod;

public class FootSlipPower extends AbstractPower {
    public static final String POWER_ID = InvincibleOneMod.makeID("FootSlipPower");
    private static final PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    public static final String NAME = powerStrings.NAME;
    public static final String[] DESC = powerStrings.DESCRIPTIONS;

    private boolean powerApplied = false;

    public FootSlipPower(AbstractCreature owner, int amount) {
        this.owner = owner;
        this.ID = POWER_ID;
        this.name = NAME;
        this.amount = amount;
        this.updateDescription();
        loadRegion("painfulStabs");
        this.type = PowerType.DEBUFF;
    }

    @Override
    public void updateDescription() {
        this.description = String.format(DESC[0], this.amount);
    }

    @Override
    public void update(int slot) {
        super.update(slot);
        if (owner.hasPower(OilStainedPower.POWER_ID) && !powerApplied) {
            powerApplied = true;
            addToBot(new ApplyPowerAction(owner, owner, new StrengthPower(owner, -this.amount)));
        } else if (!owner.hasPower(OilStainedPower.POWER_ID) && powerApplied) {
            powerApplied = false;
            addToBot(new ApplyPowerAction(owner, owner, new StrengthPower(owner, this.amount)));
        }
    }
}
